<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="common/common_head :: commonHead('web代码生成器')"></head>
</head>
<body>
<div class="x-body" style="margin: 20px auto; width: 1000px; ">

    <table border="0" cellpadding="0" cellspacing="0" class="layui-table">
        <caption><h1>页面代码生成预览</h1></caption>
        <tr>
            <th rowspan="2">表名</th>
            <th rowspan="2">实体类</th>
            <th colspan="7" align="center">属性</th>
        </tr>
        <tr>
            <th width="10%">属性名</th>
            <th width="10%">必填项</th>
            <th width="10%">控件类型</th>
            <th width="10%">页面Label名称</th>
            <th width="10%">是否主键对应属性</th>
            <th width="10%">页面中是否出现</th>
            <th width="30%">控件选项值【raido, checkbox, selected】</th>
        </tr>
        <div th:each="table : ${formList}">
            <tr>
                <td th:attr="rowspan=${#lists.size(table.fields) + 1}"><span th:text="${table.tableName}"></span></td>
                <td th:attr="rowspan=${#lists.size(table.fields) + 1}"><span th:text="${table.entityName}"></span></td>
            </tr>
            <div th:each="field : ${table.fields}">
                 <tr th:attr="style=${field.appear == true ? '' : 'color:#FFCC33'}">
                    <td><span th:text="${field.formFieldName}"></span></td>
                    <td th:attr="style=${field.required == true ? 'color: red' : ''}">
                        <span th:text="${field.required == true ? '是' : '否'}"></span></td>
                    <td>
                        <span th:if="${field.formType == 'hidden'}">隐藏域</span>
                        <span th:if="${field.formType == 'text'}">文本框</span>
                        <span th:if="${field.formType == 'textarea'}">文本域</span>
                        <span th:if="${field.formType == 'radio'}">单选框</span>
                        <span th:if="${field.formType == 'checkbox'}">复选框</span>
                        <span th:if="${field.formType == 'select'}">下拉框</span>
                        <span th:if="${field.formType == 'date'}">日期控件</span>
                        <span th:if="${field.formType == 'switch'}">switch框</span>
                    </td>
                    <td><span th:text="${field.labelName}"></span></td>
                    <td th:attr="style=${field.primaryKey == true ? 'color: red' : ''}">
                        <span th:text="${field.primaryKey == true ? '是' : '否'}"></span></td>
                    <td><span th:text="${field.appear == true ? '是' : '否'}"></span></td>
                    <td><span th:text="${field.values == null ? '' : T(com.alibaba.fastjson.JSON).toJSONString(field.values)}"></span></td>
                </tr>
            </div>
            <tr><td colspan="9"></td></tr>
        </div>
    </table>
    <form class="layui-form layui-form-pane" style="margin-left: 20px;" onsubmit="return false" >
        <div class="layui-form-item" style=" float: right;margin-right: 30px;margin-top: 8px">
            <button  class="layui-btn layui-btn-normal" id="generator">
                生成代码</button>
            <button  class="layui-btn layui-btn-primary" id="prev">上一步</button>
            <p style="color:red">【注意】: 如果代码已生成，再生成会覆盖之前的代码; <br/><br/>
                <span style="color:#FFCC33">【警告】: 黄色字体部分表示在生成页面中不出现的属性</span></p>
        </div>
    </form>
</div>
<script type="text/javascript"> /*<![CDATA[*/
layui.use(['form', 'layer'], function () {
    $ = layui.jquery;
    var form = layui.form , layer = layui.layer;

    $("#generator").click(function () {
        layer.confirm("如果代码已生成，再生成会覆盖之前的代码?", {btn: ['确定', '取消'],title:"提示"}, function () {
            var url =  /*[[@{/auto/generator}]]*/ "/auto/generator";
            var index = layer.open({title: '提示' ,content: '生成代码中。。。', type:3});
            layuiUtils.doRequest(url, {}, function () {
                layer.close(index);
                layuiUtils.toastMsg({content: '代码生成成功!',icon:'success'});
            });
        })
    })

    $("#prev").click(function () {
        var url =  /*[[@{/auto/config}]]*/ "/auto/config";
        document.location = url;
    })
});
/*]]>*/</script>
</body>
</html>
